<template>
  <el-container style="flex-direction:column;">
    <el-row style="padding-bottom: 10px;">
      <el-button type="primary" size="mini" icon="el-icon-plus" @click="add">新增</el-button>
      <el-button type="success" size="mini" icon="el-icon-edit" :disabled="multipleSelection.length !== 1">修改</el-button>
      <el-button type="danger" size="mini" icon="el-icon-delete" :disabled="multipleSelection.length == 0">删除</el-button>
      <el-button type="warning" size="mini" icon="el-icon-download">导出</el-button>
    </el-row>
    <el-table
      @selection-change="selectionChange"
      :data="tableData" size="mini"
      style="width: 100%">
      <el-table-column align="center" header-align="center"
        type="selection"
        width="55">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="id"
        label="id">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="introduction"
        label="门店名称">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="phone"
        label="门店电话">
      </el-table-column>
      <el-table-column align="center" header-align="center" show-overflow-tooltip
        prop="address"
        width="180"
        label="地址">
      </el-table-column>
      <el-table-column align="center" header-align="center" show-overflow-tooltip
        prop="dayTime"
        width="180"
        label="营业时间">
      </el-table-column>
      <el-table-column align="center" header-align="center"
        prop="isShow"
        label="是否显示">
      </el-table-column>
      <el-table-column label="操作" width="160" align="center" header-align="center" fixed="right">
        <template slot-scope="scope">
          <el-button
            size="mini"  type="primary"
            @click="handleEdit(scope.$index, scope.row)"  icon="el-icon-edit"></el-button>
          <el-button
            size="mini"
            type="danger"
            @click="handleDelete(scope.$index, scope.row)" icon="el-icon-delete"></el-button>
        </template>
      </el-table-column>
    </el-table>
    <el-pagination style="margin-top: 8px;"
      @size-change="handleSizeChange"
      @current-change="handleCurrentChange"
      :current-page="currentPage"
      :page-sizes="[100, 200, 300, 400]"
      :page-size="100"
      layout="total, prev, pager, next, sizes,jumper"
      :total="400">
    </el-pagination>
    <Store_add_or_update_dialogVue
      :title="title" 
      :visible.sync="visible" 
      @closeDialog="closeDialog"
    ></Store_add_or_update_dialogVue>
  </el-container>
</template>

<script>
import Store_add_or_update_dialogVue from "./components/Store_add_or_update_dialog.vue";
export default {
  components:{
    Store_add_or_update_dialogVue
  },
  data() {
    return {
      title:"",
      visible: false,
      currentPage:1,
      tableData: [
        {
          "id": 4,
          "name": "信阳门店",
          "introduction": "信阳门店",
          "phone": "15136275234",
          "address": "河南省信阳市",
          "detailedAddress": "",
          "image": "https://image.dayouqiantu.cn/noMeal_tt.png",
          "latitude": "32.11683",
          "longitude": "114.05857",
          "validTime": "2020-03-21 - 2020-03-31",
          "dayTime": "17:11:13 - 20:11:13",
          "createTime": null,
          "isShow": 1,
          "validTimeEnd": 1585584000000,
          "validTimeStart": 1584720000000,
          "dayTimeStart": 1584781873000,
          "dayTimeEnd": 1584792673000
        },
        {
          "id": 3,
          "name": "yshop店铺",
          "introduction": "springboot商城",
          "phone": "15136175234",
          "address": "河南省漯河市",
          "detailedAddress": "",
          "image": "https://image.dayouqiantu.cn/noMeal_tt.png",
          "latitude": "33.54528",
          "longitude": "113.9202",
          "validTime": "2020-03-09 - 2020-04-30",
          "dayTime": "11:33:49 - 19:33:49",
          "createTime": null,
          "isShow": 0,
          "validTimeEnd": 1588176000000,
          "validTimeStart": 1583683200000,
          "dayTimeStart": 1583292829000,
          "dayTimeEnd": 1583321629000
        }
      ],
      multipleSelection: [],
    }
  },
  methods: {
    handleEdit(index, row) {
      console.log(index, row);
      this.title="编辑门店";
      this.visible=true;
    },
    handleDelete(index, row) {
      console.log(index, row);
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
    },
    selectionChange(val){
      this.multipleSelection = val;
    },
    //打开dialog
    add(){
      this.title="新增门店";
      this.visible=true;
    },
    //关闭dialog
    closeDialog(){
      this.visible=false;
    },
  } 
}
</script>

<style>

</style>